<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>location</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }
    </style>
</head>
<body>
    
    <script type="text/javascript">
        // console.log(window.location === document.location);
        /* 
        location
            协议     protocol
            域名     hostname
            端口号   port
            路径     pathname
            片段     hash  可读写的值
            查询参数 search  ⭐⭐⭐  用于页面传值
            源       origin  ⭐⭐⭐
            整个URL  href  可读写的值

        方法
            location = url 跳转到某个地址
            location.href = url  跳转到某个地址
            location.assign(url) 跳转到某个地址
            location.replace(url) 跳转到某个地址，不留上一个地址的记录
            location.reload(boolean) 重载页面（是否强制）
        */
        console.log("协议", location.protocol);
        console.log("域名", location.hostname);
        console.log("端口号", location.port);
        console.log("源", location.origin);
        console.log("路径", location.pathname);
        console.log("查询参数", location.search);
        console.log("片段", location.hash);

    </script>
</body>
</html>